package com.ctsi.ssdc.controller.front;

import com.ctsi.ssdc.service.front.EconomicIndicatorsService1;
import com.ctsi.ssdc.entity.EconomicIndicators;
import com.ctsi.ssdc.entity.GeneralPublicBudgetRevenue;
import com.ctsi.ssdc.entity.MinEconomicIndicators;
import com.ctsi.ssdc.entity.QuarterlyGrossRegionalProduct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/economicIndicators")
public class EconomicIndicatorsController1 {
    @Autowired
    EconomicIndicatorsService1 economicIndicatorsService1;

    @GetMapping("/test/{year}")
    @CrossOrigin
    public List<QuarterlyGrossRegionalProduct> getQuarterlyGrossRegionalProduct1(@PathVariable("year") int year) {
        return economicIndicatorsService1.getQuarterlyGrossRegionalProduct(year);
    }

    /**
     *季度地区生产总值 和 累计
     * @param year 年份（int）
     *@return
     * List集合（包含QuarterlyGrossRegionalProduct类） {"quarter":季度（int）,
     *             "quarterValue":季度值（double）,
     *             累计
     *             "quarterOnQuarter":同比（double）}
     */
    @GetMapping("/getQuarterlyGrossRegionalProduct")
    @CrossOrigin
    public List<QuarterlyGrossRegionalProduct> getQuarterlyGrossRegionalProduct(@RequestParam int year) {
        return economicIndicatorsService1.getQuarterlyGrossRegionalProduct(year);
    }


    /**
     * 季度地区累计生产总值
     * @param year 年份（int）
     * @return
     * List集合（包含QuarterlyGrossRegionalProduct类） {"quarter":季度（int）,
     *             "quarterValue":季度值（double）,
     *             "quarterOnQuarter":同比（double）}
     */
//    @GetMapping({"/getAccumulatedQuarterlyGrossRegionalProduct"})
//    @CrossOrigin
//    public List<QuarterlyGrossRegionalProduct> getAccumulatedQuarterlyGrossRegionalProduct(@RequestParam int year) {
//        return economicIndicatorsService1.getAccumulatedQuarterlyGrossRegionalProduct(year);
//    }

    /**年度任务及单位
     *
     * @param year 年份（int）,indicators 指标 (String)
     *
     * @return
     * EconomicIndicators类{"id","indicators":指标（string）,"unit":单位（string）,"thisMonth":,"accumulate":,"monthOnMonth":,
     * "total":年度任务总量（string）,"growthRate":年度任务增速（string）,"schedule":年度任务完成进度（double）,"statisticalTime":日期（date）,"month":月,"year":年}
     *
     * 只需要"unit":单位（string）,"total":年度任务总量（string）,"growthRate":年度任务增速（string）,"schedule":年度任务完成进度（double）,"year":年（int））即可，其他不需要
     *
     */
    @GetMapping("/getAnnualTasks")
    @CrossOrigin
    public EconomicIndicators getAnnualTasks(@RequestParam int year, @RequestParam String indicators) {
        return economicIndicatorsService1.getAnnualTasks(year,indicators);
    }


    /**
     * 一般公共预算收入
     * @param year 年份（int）
     * @return
     * List集合（包含GeneralPublicBudgetRevenue类）
     * {   private int month 月份;
     *     private double thisMonth 当月;
     *     private double monthOnMonth 同比;
     *     private double accumulate 累计;
     *     private double taxProportion 税收占比;}
     */

    @GetMapping({"/getGeneralPublicBudgetRevenue"})
    @CrossOrigin
    public List<GeneralPublicBudgetRevenue> getGeneralPublicBudgetRevenue(@RequestParam int year) {
        return economicIndicatorsService1.getGeneralPublicBudgetRevenue(year);
    }


    /**
     * 全社会固定资产投资
     * 工业投资
     * 规上工业总产值
     * 社会消费品零售总额
     * 进出口总额
     * 出口总额
     * 实际使用外资
     * @param year 年份（int）
     * @param indicators 指标 （String）
     * @return
     * List集合（包含MinEconomicIndicators类）
     * {   private int month 月份;
     *     private double thisMonth 当月;
     *     private double monthOnMonth 同比;
     *     private double accumulate 累计;}
     */

    @GetMapping({"/getEconomicIndicatorsByIndicators"})
    @CrossOrigin
    public List<MinEconomicIndicators> getEconomicIndicatorsByIndicators(@RequestParam int year, @RequestParam String indicators) {
        return economicIndicatorsService1.getEconomicIndicatorsByIndicators(year, indicators);
    }

    @GetMapping({"/getAllqy"})
    @CrossOrigin
    public int getAllqy(@RequestParam int year, @RequestParam int month) {
        return economicIndicatorsService1.getAllqy(year,month);
    }
}
